package org.liveboardgames.agricola.control.delegates.action.prerequisite
{
	import org.liveboardgames.agricola.control.delegates.helper.GameHelper;
	import org.liveboardgames.agricola.vo.player.Player;
	
	public class FencePrerequisiteChecker extends PrerequisiteChecker
	{				
		public function FencePrerequisiteChecker(player:Player)
		{
			super(player);
		}
		
		override public function check():Boolean
		{
			var result:Boolean = false;
			
			// TODO: Check that the player has enough fences and wood to build the smallest possible pasture
			// Number of remaining fences
			var remainingFences:int = GameHelper.getRemainingFences(player.farm);
			
			// Can build a pasture with this numbre of remaining fences
			result = (remainingFences > 0);
			
			// Check that there is at least one free space
			var hasEmtySpace:Boolean = GameHelper.hasEmptySpace(player.farm);
			result = result && hasEmtySpace;		
			
			return result;
		}
	}
}